from django.db import models

# Create your models here.
from mlh.utils.models import BaseModel


class Spitslots(BaseModel):
    content = models.TextField(verbose_name='吐槽内容')
    user = models.ForeignKey('users.User', on_delete=models.CASCADE, related_name='spitslot', verbose_name='作者')
    sp_like_count = models.IntegerField(verbose_name='吐槽点赞次数')
    share_count = models.IntegerField(verbose_name='分享量')
    index_image_url = models.ImageField(upload_to='spitslotpackge', verbose_name='吐槽图片')
    is_collected = models.BooleanField(default=0, verbose_name='收藏状态')
    is_like = models.BooleanField(default=0, verbose_name='点赞状态')
    is_cryptonym = models.BooleanField(default=0, verbose_name='匿名状态')
    is_delete = models.BooleanField(default=True, verbose_name='逻辑删除')
    create_time = models.DateField(verbose_name='创建时间')



    class Meta:
        db_table = 'tb_spitslot'
        verbose_name = '吐槽'
        verbose_name_plural = verbose_name

    def __str__(self):
        return "吐槽"



class Spitslot_Comment(BaseModel):
    spitslot_content = models.TextField(verbose_name='吐槽评论内容')
    like_count = models.IntegerField(verbose_name='点赞量')
    user_id = models.ForeignKey('users.User', on_delete=models.CASCADE, related_name='spitslot_comment', verbose_name='用户')
    spitslot_id = models.ForeignKey('Spitslots', on_delete=models.CASCADE, related_name='spitslot_comment', verbose_name='用户')
    is_like = models.BooleanField(default=0, verbose_name='点赞状态')

    class Meta:
        db_table = 'tb_sp_comment'
        verbose_name = '吐槽评论'
        verbose_name_plural = verbose_name

    def __str__(self):
        return "吐槽评论"


class Share(models.Model):
    user = models.ForeignKey('users.User', on_delete=models.CASCADE, related_name='user_share', verbose_name='分享的用户')
    spitslot = models.ForeignKey('Spitslots', on_delete=models.CASCADE, related_name='sp_share', verbose_name='分享的吐槽')


class Collection(models.Model):
    user = models.ForeignKey('users.User', on_delete=models.CASCADE, related_name='user_collection',
                             verbose_name='收藏的用户')
    spitslot = models.ForeignKey('Spitslots', on_delete=models.CASCADE, related_name='sp_collection',
                                 verbose_name='收藏的吐槽')


class Spitslot_Like(models.Model):
    user = models.ForeignKey('users.User', on_delete=models.CASCADE, related_name='user_sp_like', verbose_name='点赞的用户')
    spitslot = models.ForeignKey('Spitslots', on_delete=models.CASCADE, related_name='sp_like', verbose_name='点赞的吐槽')


class Spitslot_Comment_Like(models.Model):
    user = models.ForeignKey('users.User', on_delete=models.CASCADE, related_name='user_spcm_like', verbose_name='点赞的用户')
    spitslot = models.ForeignKey('Spitslot_Comment', on_delete=models.CASCADE, related_name='sp_spcm_like', verbose_name='点赞的吐槽')

